<?php
	$layout = $this->cmsSearch('slider'); 
	echo $layout;
	$layout = $this->cmsSubmenu(); 
	echo $layout;
	
	$items = $this->search_result;
	$loai_tin = $this->loai_tin;
	$formData = $this->formData;
	$frm_sendmail = $this->form_sendmailtoposter;
?>
<div id="wrapcontent">
	<div id="sidebar1">
		<?php
			$img = '<img src="' . $this->baseUrl(PUBLIC_PATH . "/img/icon/icon_hot.gif") . '" />';
			$block = $this->cmsBlock('Phòng trọ', $img, $this->itemsHotPtrTinTro); 
			echo $block;
		?>
		<!-- Begin Block hỗ trợ trực tuyến -->
		<?php 
			$block = $this->cmsBlock('Hỗ trợ trực tuyến', '', $this->thong_tin_cty, 3); 
			echo $block;
		?>
		<!-- End Block hỗ trợ trực tuyến -->
		<!-- Begin Block thống kê truy cập -->
		<?php 
			$block = $this->cmsBlock('Thống kê truy cập', '', 'info', 4); 
			echo $block;
		?>
		<!-- End Block thống kê truy cập -->
		<br class="clear" />
	</div>
	<div id="sidebar2">
		<div class="block">
			<div class="title">
				<span>Mạng xã hội</span>
			</div>
			<div class="content">
				<div class="follow">
					<div class="addthis_toolbox addthis_32x32_style addthis_vertical_style">
						<a class="addthis_button_facebook_follow" addthis:userid="kenhnhatro.vn"></a>
						<a class="addthis_button_twitter_follow" addthis:userid="kenh_nhatro"></a>
					</div>
				</div>
			</div>
			<br class="clear" />
		</div>
		<?php
			$img = '<img src="' . $this->baseUrl(PUBLIC_PATH . "/img/icon/icon_new.gif") . '" />';
			$block = $this->cmsBlock('Tin rao mới', $img, $this->itemsNewPtrTinTro); 
			echo $block;
			$img = '<img class="icon" src="' . $this->baseUrl(PUBLIC_PATH . "/img/icon/highlights.png") . '" />';
			$block = $this->cmsBlock('Tin tức nổi bật', $img, $this->itemsHotTinTuc, 2);
			echo $block;
		?>
	</div>
	<div id="primary">
		<?php 
		if (isset($formData)) {
			if ($this->result) {
				if ($loai_tin > 0) {
					$itemCountPerPage = $this->panigator->getItemCountPerPage();
		?>
			<div class="block">
				<div class="title">
					<span>Kết quả tìm kiếm</span>
				</div>
				<div id="searchResult" class="content">
					<?php
						$html = '';
						// Dùng kiểm tra hiển thị khung cho tin VIP
						$checkVipFirst = true;
						$checkVipEnd = false;
						foreach ($items as $val) {
							$htmlMetadata = '';
							$htmlDate = '';
							$htmlConPhong = '';
							
							$id_tin_rao	= $val->id;
							$tieu_de 	= $val->tieu_de;
							$luot_xem 	= $val->luot_xem;
							$ngay_dang 	= $val->ngay_dang;
							$goi_tin	= $val->goi_tin;
							$displayVIP = '';
							if ($goi_tin != 4) {
								$displayVIP = '<div class="icon_vip"></div>';
								if ($checkVipFirst) {
									$html .= '<div class="box-vip">';
									$checkVipFirst = false;
									$checkVipEnd = true;
								}
							} elseif ($checkVipEnd) {
								$html .= '</div>';
								$checkVipEnd = false;
							}
							
							// Kiểm tra loại tin là tìm người ở trọ hay tìm phòng trọ để thay đổi giao diện
							if ($loai_tin > 1) {
								$img 		= $val->hinh_anh;
								$hinh_anh 	= '/phong_tro/avatar/' . $img;
								if (preg_match("/(.*)[,](.*)/", $img)) {
									$list_image = explode (',', $img);
									$hinh_anh = '/phong_tro/avatar/' . $list_image[0];
								}
								
								$htmlMetadata .= '<div class="metadata">';
								$htmlMetadata .= '<img src="' . $this->baseUrl(PUBLIC_IMG_URL . $hinh_anh) . '" alt="' . $val->tieu_de . '" width="64px" height="64px" onerror="this.onerror=null; this.src=\'' . $this->baseUrl(PUBLIC_IMG_URL . '/phong_tro/avatar/error_avatar_home.png') . '\';" />';
								$htmlMetadata .= '<ul>';
								$htmlMetadata .= '<li class="label-view">Số lượt xem</li>';
								$htmlMetadata .= '<li class="num-view">' . $luot_xem . '</li>';
								$htmlMetadata .= '</ul>';
								$htmlMetadata .= '</div>';
								
								$htmlDate .= '<div class="date post-date">' . $ngay_dang . $displayVIP . '</div>';
								
								if ($this->group_loai_tin == 0) {
									$con_phong 	= $val->con_phong;
									if ($con_phong)
										$htmlConPhong .= '<div class="icon_con_phong"></div>';
								}
							} else {
								$htmlDate .= '<div class="date"><span class="post-date">' . $ngay_dang . '</span>';
								$htmlDate .= '<span class="view"><b>' . $luot_xem . '</b> Lượt xem</span><div class="icon_vip"></div></div>';
							}
							$dia_chi 	= $val->dia_chi;
							if ($this->group_loai_tin == 0) {
								$gia = $val->gia_phong;
								$dien_tich 	= $val->dien_tich;
							} else {
								$gia = $val->gia_o_ghep;
								$dien_tich 	= $val->dien_tich_phong;
							}
							$gia_phong 	= number_format($gia, 3, ",", ",") . ' VNĐ';
							if ($gia == null || $gia == 0)
								$gia_phong = 'Thỏa thuận';
							$quan_huyen	= $val->getQuanHuyenObj();
							$nguoi_dang = $val->getNguoiDangObj();
							$email 		= $nguoi_dang->email;
							$html .= '<div class="item">';
							$html .= $htmlMetadata;
							$html .= '<a title="' . $tieu_de . '" rel="bookmark" href="' . $this->baseUrl("/" . $this->detailAction . "/view/id/" . $id_tin_rao) . '">' . Zendhlt_Encode::truncateString_($tieu_de, 48). '</a>';
							$html .= $htmlDate;
							$html .= '<div class="info">';
							$html .= 'Địa chỉ: ' . $dia_chi . '<br />';
							$html .= 'Giá phòng: <span class="price">' . $gia_phong . '</span><br />';
							$html .= 'Diện tích: ' . $dien_tich . ' m<sup>2</sup><br />';
							$html .= '<div class="district">' . $quan_huyen->ten . '<br />';
							$html .= '<a class="send_email" title="Gửi email đến người đăng" href="#sendMailModal" data-toggle="modal" onclick="setVal(\'' . $this->detailAction . '\', ' . $id_tin_rao . ', ' . $nguoi_dang->id . ', \'' . $nguoi_dang->email . '\')"><img src="' . $this->baseUrl(DEFAULT_PATH . '/img/icon_email.png') . '" alt="' . $email . '" /></a>';
							$html .= $htmlConPhong;
							$html .= '</div>';
							$html .= '</div>';
							$html .= '<div class="clear"></div></div>';
						}
						if ($checkVipEnd) {
							$html .= '</div>';
							$checkVipEnd = false;
						}
						echo $html;
					?>
					<?php if ($this->totalItem > $itemCountPerPage) {?>
						<div class="pagenavi">
							<div class="pagination">
							<?php
								echo $this->paginationControl($this->panigator, 'Sliding', 'pagination.phtml', array('ajax' => "'#searchResult', 'search/rc/10/tt/" . $formData['idtinhthanh'] . "/qh/" . $formData['idquanhuyen'] . "/g/" . $formData['idgia'] . "/dt/" . $formData['iddientich'] . "/lp/" . $formData['idloaiphong'] . "/sng/" . $formData['idsonguoio'] . "', " . $formData['idloaitin'] . ", "));
							?>
							</div>
							<br class="clear" />
						</div>
					<?php } ?>
				</div>
				<br class="clear" />
			</div>
		<?php } else {
					$itemCountPerPage = $this->itemCountPerPage;
					$title = array(array('id' => 2, 'pane1' => 'Phòng cho thuê'), array('id' => 1, 'pane2' => 'Tìm phòng trọ'));
					
					// Hiển thị items tìm người ở trọ của table Ptr_Tin_Rao
					$htmlTNPtrTinTro = '';
					// Dùng kiểm tra hiển thị khung cho tin VIP
					$checkVipFirst = true;
					$checkVipEnd = false;
					foreach ($this->itemsTNPtrTinTro as $val) {
						$id_tin_rao	= $val->id;
						$tieu_de 	= $val->tieu_de;
						$goi_tin	= $val->goi_tin;
						$displayVIP = '';
						if ($goi_tin != 4) {
							$displayVIP = '<div class="icon_vip"></div>';
							if ($checkVipFirst) {
								$htmlTNPtrTinTro .= '<div class="box-vip">';
								$checkVipFirst = false;
								$checkVipEnd = true;
							}
						} elseif ($checkVipEnd) {
							$htmlTNPtrTinTro .= '</div>';
							$checkVipEnd = false;
						}
						
						$img 		= $val->hinh_anh;
						$hinh_anh 	= '/phong_tro/avatar/' . $img;
						$luot_xem 	= $val->luot_xem;
						$ngay_dang 	= $val->ngay_dang;
						$dia_chi 	= $val->dia_chi;
						$gia_phong 	= number_format($val->gia_phong, 3, ",", ",") . ' VNĐ';
						if ($val->gia_phong == null || $val->gia_phong == 0)
							$gia_phong = 'Thỏa thuận';
						$dien_tich 	= $val->dien_tich;
						$con_phong 	= $val->con_phong;
						$quan_huyen	= $val->getQuanHuyenObj();
						$nguoi_dang = $val->getNguoiDangObj();
						$email 		= $nguoi_dang->email;
						if (preg_match("/(.*)[,](.*)/", $img)) {
							$list_image = explode (',', $img);
							$hinh_anh = '/phong_tro/avatar/' . $list_image[0];
						}
						$htmlTNPtrTinTro .= '<div class="item">';
						$htmlTNPtrTinTro .= '<div class="metadata">';
						$htmlTNPtrTinTro .= '<img src="' . $this->baseUrl(PUBLIC_IMG_URL . $hinh_anh) . '" alt="' . $val->tieu_de . '" width="64px" height="64px" onerror="this.onerror=null; this.src=\'' . $this->baseUrl(PUBLIC_IMG_URL . '/phong_tro/avatar/error_avatar_home.png') . '\';" />';
						$htmlTNPtrTinTro .= '<ul>';
						$htmlTNPtrTinTro .= '<li class="label-view">Số lượt xem</li>';
						$htmlTNPtrTinTro .= '<li class="num-view">' . $luot_xem . '</li>';
						$htmlTNPtrTinTro .= '</ul>';
						$htmlTNPtrTinTro .= '</div>';
						$htmlTNPtrTinTro .= '<a title="' . $tieu_de . '" rel="bookmark" href="' . $this->baseUrl("/ptrtinrao/view/id/" . $id_tin_rao) . '">' . Zendhlt_Encode::truncateString_($tieu_de, 48). '</a>';
						$htmlTNPtrTinTro .= '<div class="date post-date">' . $ngay_dang . $displayVIP . '</div>';
						$htmlTNPtrTinTro .= '<div class="info">';
						$htmlTNPtrTinTro .= 'Địa chỉ: ' . $dia_chi . '<br />';
						$htmlTNPtrTinTro .= 'Giá phòng: <span class="price">' . $gia_phong . '</span><br />';
						$htmlTNPtrTinTro .= 'Diện tích: ' . $dien_tich . ' m<sup>2</sup><br />';
						$htmlTNPtrTinTro .= '<div class="district">' . $quan_huyen->ten . '<br />';
						if ($con_phong)
							$htmlTNPtrTinTro .= '<div class="icon_con_phong"></div>';
						$htmlTNPtrTinTro .= '<a class="send_email" title="Gửi email đến người đăng" href="#sendMailModal" data-toggle="modal" onclick="setVal(\'ptrtinrao\', ' . $id_tin_rao . ', ' . $nguoi_dang->id . ', \'' . $nguoi_dang->email . '\')"><img src="' . $this->baseUrl(DEFAULT_PATH . '/img/icon_email.png') . '" alt="' . $email . '" /></a>';
						$htmlTNPtrTinTro .= '</div>';
						$htmlTNPtrTinTro .= '</div>';
						$htmlTNPtrTinTro .= '<div class="clear"></div></div>';
					};
					if ($checkVipEnd) {
						$htmlTNPtrTinTro .= '</div>';
						$checkVipEnd = false;
					}
					if ($this->totalItemTNPtrTinTro > $itemCountPerPage) {
						$htmlTNPtrTinTro .= '<div class="pagenavi">';
						$htmlTNPtrTinTro .= '<div id="TNPtrTinTro" class="pagination">';
						$htmlTNPtrTinTro .= $this->paginationControl($this->panigatorTNPtrTinTro, 'Sliding', 'pagination.phtml', array('ajax' => "'#tab1_pane1', 'search/tt/" . $formData['idtinhthanh'] . "/qh/" . $formData['idquanhuyen'] . "/g/" . $formData['idgia'] . "/dt/" . $formData['iddientich'] . "/lp/" . $formData['idloaiphong'] . "/sng/" . $formData['idsonguoio'] . "', 2, "));
						$htmlTNPtrTinTro .= '</div>';
						$htmlTNPtrTinTro .= '<br class="clear" /></div>';
					}
					
					// Hiển thị items tìm phòng trọ của table Ptr_Tin_Rao
					$htmlTPtrPtrTinTro = '';
					// Dùng kiểm tra hiển thị khung cho tin VIP
					$checkVipFirst = true;
					$checkVipEnd = false;
					foreach ($this->itemsTPtrPtrTinTro as $val) {
						$id_tin_rao	= $val->id;
						$tieu_de 	= $val->tieu_de;
						$luot_xem 	= $val->luot_xem;
						$goi_tin	= $val->goi_tin;
						$displayVIP = '';
						if ($goi_tin != 4) {
							$displayVIP = '<div class="icon_vip"></div>';
							if ($checkVipFirst) {
								$htmlTPtrPtrTinTro .= '<div class="box-vip">';
								$checkVipFirst = false;
								$checkVipEnd = true;
							}
						} elseif ($checkVipEnd) {
							$htmlTPtrPtrTinTro .= '</div>';
							$checkVipEnd = false;
						}
						$ngay_dang 	= $val->ngay_dang;
						$dia_chi 	= $val->dia_chi;
						$gia_phong 	= number_format($val->gia_phong, 3, ",", ",") . ' VNĐ';
						if ($val->gia_phong == null || $val->gia_phong == 0)
							$gia_phong = 'Thỏa thuận';
						$dien_tich 	= $val->dien_tich;
						$quan_huyen	= $val->getQuanHuyenObj();
						$nguoi_dang = $val->getNguoiDangObj();
						$email 		= $nguoi_dang->email;
						$htmlTPtrPtrTinTro .= '<div class="item">';
						$htmlTPtrPtrTinTro .= '<a title="' . $tieu_de . '" rel="bookmark" href="' . $this->baseUrl("/ptrtinrao/view/id/" . $id_tin_rao) . '">' . Zendhlt_Encode::truncateString_($tieu_de, 48). '</a>';
						$htmlTPtrPtrTinTro .= '<div class="date"><span class="post-date">' . $ngay_dang . '</span>';
						$htmlTPtrPtrTinTro .= '<span class="view"><b>' . $luot_xem . '</b> Lượt xem</span>' . $displayVIP . '</div>';
						$htmlTPtrPtrTinTro .= '<div class="info">';
						$htmlTPtrPtrTinTro .= 'Địa chỉ: ' . $dia_chi . '<br />';
						$htmlTPtrPtrTinTro .= 'Giá phòng: <span class="price">' . $gia_phong . '</span><br />';
						$htmlTPtrPtrTinTro .= 'Diện tích: ' . $dien_tich . ' m<sup>2</sup><br />';
						$htmlTPtrPtrTinTro .= '<div class="district">' . $quan_huyen->ten . '<br />';
						$htmlTPtrPtrTinTro .= '<a class="send_email" title="Gửi email đến người đăng" href="#sendMailModal" data-toggle="modal" onclick="setVal(\'ptrtinrao\', ' . $id_tin_rao . ', ' . $nguoi_dang->id . ', \'' . $nguoi_dang->email . '\')"><img src="' . $this->baseUrl(DEFAULT_PATH . '/img/icon_email.png') . '" alt="' . $email . '" /></a>';
						$htmlTPtrPtrTinTro .= '</div>';
						$htmlTPtrPtrTinTro .= '</div>';
						$htmlTPtrPtrTinTro .= '<div class="clear"></div></div>';
					}
					if ($checkVipEnd) {
						$htmlTPtrPtrTinTro .= '</div>';
						$checkVipEnd = false;
					}
					if ($this->totalItemTPtrPtrTinTro > $itemCountPerPage) {
						$htmlTPtrPtrTinTro .= '<div class="pagenavi">';
						$htmlTPtrPtrTinTro .= '<div id="TPtrPtrTinTro" class="pagination">';
						$htmlTPtrPtrTinTro .= $this->paginationControl($this->panigatorTPtrPtrTinTro, 'Sliding', 'pagination.phtml', array('ajax' => "'#tab1_pane2', 'search/tt/" . $formData['idtinhthanh'] . "/qh/" . $formData['idquanhuyen'] . "/g/" . $formData['idgia'] . "/dt/" . $formData['iddientich'] . "/lp/" . $formData['idloaiphong'] . "/sng/" . $formData['idsonguoio'] . "', 1, "));
						$htmlTPtrPtrTinTro .= '</div>';
						$htmlTPtrPtrTinTro .= '<br class="clear" /></div>';
					}
					
					$info = array('pane1' => $htmlTNPtrTinTro, 'pane2' => $htmlTPtrPtrTinTro);
					$block = $this->cmsBlockTabs($title, '', $info, 'tab1', 'onclick="changeReadmore(this, \'#ptr\', \'ptrtinrao\');"'); 
					echo $block;
					
					$title = array(array('id' => 3, 'pane1' => 'Cần ở ghép'), array('id' => 4, 'pane2' => 'Tìm người ở ghép'));
					
					// Hiển thị items cần ở ghép của table Ogh_Tin_Rao
					$htmlCOGOghTinTro = '';
					// Dùng kiểm tra hiển thị khung cho tin VIP
					$checkVipFirst = true;
					$checkVipEnd = false;
					foreach ($this->itemsCOGOghTinTro as $val) {
						$id_tin_rao	= $val->id;
						$tieu_de 	= $val->tieu_de;
						$goi_tin	= $val->goi_tin;
						$displayVIP = '';
						if ($goi_tin != 4) {
							$displayVIP = '<div class="icon_vip"></div>';
							if ($checkVipFirst) {
								$htmlCOGOghTinTro .= '<div class="box-vip">';
								$checkVipFirst = false;
								$checkVipEnd = true;
							}
						} elseif ($checkVipEnd) {
							$htmlCOGOghTinTro .= '</div>';
							$checkVipEnd = false;
						}
						$hinh_anh 	= '/phong_tro/avatar/' . $val->hinh_anh;
						$luot_xem 	= $val->luot_xem;
						$ngay_dang 	= $val->ngay_dang;
						$dia_chi 	= $val->dia_chi;
						$gia_phong 	= number_format($val->gia_o_ghep, 3, ",", ",") . ' VNĐ';
						if ($val->gia_o_ghep == null || $val->gia_o_ghep == 0)
							$gia_phong = 'Thỏa thuận';
						$dien_tich 	= $val->dien_tich_phong;
						$quan_huyen	= $val->getQuanHuyenObj();
						$nguoi_dang = $val->getNguoiDangObj();
						$email		= $nguoi_dang->email;
						$htmlCOGOghTinTro .= '<div class="item">';
						$htmlCOGOghTinTro .= '<div class="metadata">';
						$htmlCOGOghTinTro .= '<img src="' . $this->baseUrl(PUBLIC_IMG_URL . $hinh_anh) . '" alt="' . $val->tieu_de . '" width="64px" height="64px" onerror="this.onerror=null; this.src=\'' . $this->baseUrl(PUBLIC_IMG_URL . '/phong_tro/avatar/error_avatar_home.png') . '\';" />';
						$htmlCOGOghTinTro .= '<ul>';
						$htmlCOGOghTinTro .= '<li class="label-view">Số lượt xem</li>';
						$htmlCOGOghTinTro .= '<li class="num-view">' . $luot_xem . '</li>';
						$htmlCOGOghTinTro .= '</ul>';
						$htmlCOGOghTinTro .= '</div>';
						$htmlCOGOghTinTro .= '<a title="' . $tieu_de . '" rel="bookmark" href="' . $this->baseUrl("/oghtinrao/view/id/" . $id_tin_rao) . '">' . Zendhlt_Encode::truncateString_($tieu_de, 48). '</a>';
						$htmlCOGOghTinTro .= '<div class="date post-date">' . $ngay_dang . $displayVIP . '</div>';
						$htmlCOGOghTinTro .= '<div class="info">';
						$htmlCOGOghTinTro .= 'Địa chỉ: ' . $dia_chi . '<br />';
						$htmlCOGOghTinTro .= 'Giá phòng: <span class="price">' . $gia_phong . '</span><br />';
						$htmlCOGOghTinTro .= 'Diện tích: ' . $dien_tich . ' m<sup>2</sup><br />';
						$htmlCOGOghTinTro .= '<div class="district">' . $quan_huyen->ten . '<br />';
						$htmlCOGOghTinTro .= '<a class="send_email" title="Gửi email đến người đăng" href="#sendMailModal" data-toggle="modal" onclick="setVal(\'oghtinrao\', ' . $id_tin_rao . ', ' . $nguoi_dang->id . ', \'' . $nguoi_dang->email . '\')"><img src="' . $this->baseUrl(DEFAULT_PATH . '/img/icon_email.png') . '" alt="' . $email . '" /></a>';
						$htmlCOGOghTinTro .= '</div>';
						$htmlCOGOghTinTro .= '</div>';
						$htmlCOGOghTinTro .= '<div class="clear"></div></div>';
					};
					if ($checkVipEnd) {
						$htmlCOGOghTinTro .= '</div>';
						$checkVipEnd = false;
					}
					if ($this->totalItemCOGOghTinTro > $itemCountPerPage) {
						$htmlCOGOghTinTro .= '<div class="pagenavi">';
						$htmlCOGOghTinTro .= '<div id="COGOghTinTro" class="pagination">';
						$htmlCOGOghTinTro .= $this->paginationControl($this->panigatorCOGOghTinTro, 'Sliding', 'pagination.phtml', array('ajax' => "'#tab2_pane1', 'search/tt/" . $formData['idtinhthanh'] . "/qh/" . $formData['idquanhuyen'] . "/g/" . $formData['idgia'] . "/dt/" . $formData['iddientich'] . "/lp/" . $formData['idloaiphong'] . "/sng/" . $formData['idsonguoio'] . "', 3, "));
						$htmlCOGOghTinTro .= '</div>';
						$htmlCOGOghTinTro .= '<br class="clear" /></div>';
					}
					
					// Hiển thị items tìm người ở ghép của table Ogh_Tin_Rao
					$htmlTNOGOghTinTro = '';
					// Dùng kiểm tra hiển thị khung cho tin VIP
					$checkVipFirst = true;
					$checkVipEnd = false;
					foreach ($this->itemsTNOGOghTinTro as $val) {
						$id_tin_rao	= $val->id;
						$tieu_de 	= $val->tieu_de;
						$goi_tin	= $val->goi_tin;
						$displayVIP = '';
						if ($goi_tin != 4) {
							$displayVIP = '<div class="icon_vip"></div>';
							if ($checkVipFirst) {
								$htmlTNOGOghTinTro .= '<div class="box-vip">';
								$checkVipFirst = false;
								$checkVipEnd = true;
							}
						} elseif ($checkVipEnd) {
							$htmlTNOGOghTinTro .= '</div>';
							$checkVipEnd = false;
						}
						$hinh_anh	= '/phong_tro/avatar/' . $val->hinh_anh;
						$luot_xem 	= $val->luot_xem;
						$ngay_dang 	= $val->ngay_dang;
						$dia_chi 	= $val->dia_chi;
						$gia_phong 	= number_format($val->gia_o_ghep, 3, ",", ",") . ' VNĐ';
						if ($val->gia_o_ghep == null || $val->gia_o_ghep == 0)
							$gia_phong = 'Thỏa thuận';
						$dien_tich 	= $val->dien_tich_phong;
						$quan_huyen	= $val->getQuanHuyenObj();
						$nguoi_dang = $val->getNguoiDangObj();
						$email 		= $nguoi_dang->email;
						$htmlTNOGOghTinTro .= '<div class="item">';
						$htmlTNOGOghTinTro .= '<div class="metadata">';
						$htmlTNOGOghTinTro .= '<img src="' . $this->baseUrl(PUBLIC_IMG_URL . $hinh_anh) . '" alt="' . $val->tieu_de . '" width="64px" height="64px" onerror="this.onerror=null; this.src=\'' . $this->baseUrl(PUBLIC_IMG_URL . '/phong_tro/avatar/error_avatar_home.png') . '\';" />';
						$htmlTNOGOghTinTro .= '<ul>';
						$htmlTNOGOghTinTro .= '<li class="label-view">Số lượt xem</li>';
						$htmlTNOGOghTinTro .= '<li class="num-view">' . $luot_xem . '</li>';
						$htmlTNOGOghTinTro .= '</ul>';
						$htmlTNOGOghTinTro .= '</div>';
						$htmlTNOGOghTinTro .= '<a title="' . $tieu_de . '" rel="bookmark" href="' . $this->baseUrl("/oghtinrao/view/id/" . $id_tin_rao) . '">' . Zendhlt_Encode::truncateString_($tieu_de, 48). '</a>';
						$htmlTNOGOghTinTro .= '<div class="date post-date">' . $ngay_dang . $displayVIP . '</div>';
						$htmlTNOGOghTinTro .= '<div class="info">';
						$htmlTNOGOghTinTro .= 'Địa chỉ: ' . $dia_chi . '<br />';
						$htmlTNOGOghTinTro .= 'Giá phòng: <span class="price">' . $gia_phong . '</span><br />';
						$htmlTNOGOghTinTro .= 'Diện tích: ' . $dien_tich . ' m<sup>2</sup><br />';
						$htmlTNOGOghTinTro .= '<div class="district">' . $quan_huyen->ten . '<br />';
						$htmlTNOGOghTinTro .= '<a class="send_email" title="Gửi email đến người đăng" href="#sendMailModal" data-toggle="modal" onclick="setVal(\'oghtinrao\', ' . $id_tin_rao . ', ' . $nguoi_dang->id . ', \'' . $nguoi_dang->email . '\')"><img src="' . $this->baseUrl(DEFAULT_PATH . '/img/icon_email.png') . '" alt="' . $email . '" /></a>';
						$htmlTNOGOghTinTro .= '</div>';
						$htmlTNOGOghTinTro .= '</div>';
						$htmlTNOGOghTinTro .= '<div class="clear"></div></div>';
					}
					if ($checkVipEnd) {
						$htmlTNOGOghTinTro .= '</div>';
						$checkVipEnd = false;
					}
					if ($this->totalItemCOGOghTinTro > $itemCountPerPage) {
						$htmlTNOGOghTinTro .= '<div class="pagenavi">';
						$htmlTNOGOghTinTro .= '<div id="TNOGOghTinTro" class="pagination">';
						$htmlTNOGOghTinTro .= $this->paginationControl($this->panigatorTNOGOghTinTro, 'Sliding', 'pagination.phtml', array('ajax' => "'#tab2_pane2', 'search/tt/" . $formData['idtinhthanh'] . "/qh/" . $formData['idquanhuyen'] . "/g/" . $formData['idgia'] . "/dt/" . $formData['iddientich'] . "/lp/" . $formData['idloaiphong'] . "/sng/" . $formData['idsonguoio'] . "', 4, "));
						$htmlTNOGOghTinTro .= '</div>';
						$htmlTNOGOghTinTro .= '<br class="clear" /></div>';
					}
					
					$info = array('pane1' => $htmlCOGOghTinTro, 'pane2' => $htmlTNOGOghTinTro);
					$block = $this->cmsBlockTabs($title, '', $info, 'tab2', 'onclick="changeReadmore(this, \'#ogh\', \'oghtinrao\');"'); 
					echo $block;
				}
			} else { ?>
				<div class="block">
					<div class="title">
						<span>Kết quả tìm kiếm</span>
					</div>
					<div class="content">
						<p>Không tìm thấy tin theo yêu cầu.</p>
					</div>
				</div>
			<?php } 
		} else { ?>
			<div class="block">
				<div class="title">
					<span>Kết quả tìm kiếm</span>
				</div>
				<div class="content">
					<p>Chưa chọn các giá trị cần tìm kiếm.</p>
				</div>
			</div>
		<?php } ?>
	</div>
	<!-- SEND MAIL CHO NGUOI DANG MODAL -->
	<div id="sendMailModal" class="modal hide fade" tabindex="-1"
		role="dialog" aria-labelledby="sendMailModalLabel" aria-hidden="true">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal"
				aria-hidden="true">×</button>
			<h3 id="sendMailModalLabel">Gửi cho người đăng tin</h3>
		</div>
		<div class="modal-body">
			<div id="sendmailalert" class="alert"></div>
			<form class="form-horizontal">
				<?php 
					echo $frm_sendmail->loai_bai_dang;
					echo $frm_sendmail->id_bai_dang;
					echo $frm_sendmail->id_nguoi_dang;
					echo $frm_sendmail->email_nguoi_dang;
				?>
				<div class="control-group">
					<label class="control-label" for="nguoi_gui">Tên của bạn</label>
					<div class="controls">
					<?php echo $frm_sendmail->nguoi_gui;?>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="email_nguoi_gui">Email của bạn</label>
					<div class="controls">
					<?php echo $frm_sendmail->email_nguoi_gui;?>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="subject">Tiêu đề (Subject)</label>
					<div class="controls">
					<?php echo $frm_sendmail->subject;?>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="message">Thông điệp (Message)</label>
					<div class="controls">
						<?php echo $frm_sendmail->message;?>
					</div>
				</div>
			</form>
		</div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">Bỏ qua</button>
			<button id="btnSendMail" class="btn btn-primary">Gửi</button>
		</div>
	</div>
	<script type="text/javascript">
		//Catch keydown event of the enter key
		$('#sendMailModal').keydown(function (e) {
			if(e.keyCode == 13) {
				sendForFriendProcess(e);
			}
		});
		//Catch click event of the send mail button
		$('#btnSendMail').click(function(e) {
			sendMailProcess(e);
		});
		
		$('#sendmail').click(function() {
			$('#sendmailalert').hide();
		});
		
		//Show the modal event processing
		$('#sendMailModal').on('show', function () {
			$(this).find('.alert').hide();
			$(this).find("input").each(function() {
				var inputid = $(this).attr('id');
				$("#"+inputid).parent().find('.errors').remove();
				$("#"+inputid+'[type="text"]').val("");
		    });
			$(this).find("textarea").each(function() {
				var inputid = $(this).attr('id');
				$("#"+inputid).val("");
		    });
		});
		
		$(function(){
			$('#sendMailModal').find("input").each(function() {
		        var inputid = $(this).attr('id');
		        $("#"+inputid).blur(function() {
		        	if(doValidation('sendMailModal', inputid, '/ajax/validatesendmail', null))
		        		$("#btnSendMail").removeAttr("disabled");
		        	else
		        		$("#btnSendMail").attr("disabled", "disabled");	
		        });
		    });
		});
		//Process send mail function
		function sendMailProcess(event) {
			var url = '/ajax/sendmail';
			var $this = $(this);
			var postData = $("#sendMailModal form").serializeObject();
			postData.format = "json";
			var isValid = true;
			$('#sendMailModal').find("input").each(function() {
				var inputid = $(this).attr('id');
				isValid = isValid&&doValidation('sendMailModal', inputid, '/ajax/validatesendmail', 'validate');
		    });
			if(isValid){
				$("#btnSendMail").attr("disabled", "disabled");
				$.ajax({
		            type: 'POST',
		            url: url,
		            async: true,
		            cache: true,
		            data: postData,
		            dataType: postData.format,
		            success: function(data){
		            	if(data.result) {
	                		$('#sendmailalert').html(data.message);
	                		$('#sendmailalert').show();
		            		setTimeout(function() {
								$('#sendMailModal').modal('hide'); 
							}, 1000);
		            	} else {
		            		if(data.message){
		                		$('#sendmailalert').html(data.message);
		                		$('#sendmailalert').show();
		                    }
		                }
		            }
		        });
				$("#btnSendMail").removeAttr("disabled");
			}
		}

		function setVal (loai, id, ndang, endang) {
			$('#loai_bai_dang').val(loai);
			$('#id_bai_dang').val(id);
			$('#id_nguoi_dang').val(ndang);
			$('#email_nguoi_dang').val(endang);
		}
	</script>
   	<div class="clear"></div>
</div>